<include file="Index:header"/>
<include file="Index:infoarea"/>
<!-- page content start -->
<div class='content_box'>
    <link rel="stylesheet" href="{:RES}/jfb/css/exchange.css">
    <script type="text/javascript">
    function page_onload(){
        //此方法在页面加载完毕后调用
        $('.btn_on').on('click',function(){
            //ajax获取是否有积分
            var wechat_id = "{$wechat_id}";
            $.ajax({
                type: "POST",
                url: "/Wap/Api/exchangeCheck.html",
                data: {wechat_id:wechat_id},
                dataType: "json",
                success: function(data){
                    if(data.success==0){
                        alert(data.code);
                    }else{
                        var yesfunction = function(){
                            $('.alert_yn_box').fadeOut(200);
                            window.location.href = '/Wap/Index/addressform.html';
                        }
                        showAlertYesNo('确认用{$prizeinfo.cost}积分兑换{$prizeinfo.name}?',yesfunction);
                    }
                },error:function(){
                    alert('error');
                }
            });
        });
    }
    </script>


    <div class='prize_info'>
        <img src="{:RES}/jfb/images/prize_info.jpg"/>
    </div>
    <div class='prize_btn'>
        <if condition="$userinfo['integral'] egt $prizeinfo['cost']">
            <if condition="$prizeinfo['count']-$prizeinfo['odd'] gt 0">
                <span class='btn_on' style='display: block;'>立即兑换</span>
            <else/>
                <span class='btn_no' style='display: block;'>库存不足</span>
            </if>
        <else/>
            <span class='btn_no' style='display: block;'>积分不足</span>
        </if>
    </div>
</div>
<!-- page content end -->
<include file="Index:footer"/>
